#include <iostream>
#include <algorithm>
using namespace std;
 long long  m, n;
const int N = 1e5 + 10;
long long  school[N];
long long  student[N];
 
 int find(long long b)
 {
 	
 	int left=1,right=m;
 	while(left<right)
 	{
 		int mid=(left+right)/2;
 		if(school[mid]>=b)right=mid;
 		else left=mid+1;
	 }
	 return left;
 }
int main() {
    
    cin >> m >> n;
    for(int i = 1; i <= m; i++)
	 {
        cin >> school[i];
    }
    for(int i = 1; i <= n; i++)
	 {
        cin >> student[i];
    }
    
    sort(school+1,school+1+m);
    
    school[0]= -1e7+10;
    *(school+m+2)=1e7+10; 
	 
	 long long sum=0;
	 
    for(int i=1;i<=n;i++)
	{
	
		int pos =find(student[i]);
		long long ret=min(abs(school[pos]-student[i]),abs(school[pos-1]-student[i]));
	
     	sum+=ret;
	}  
  
  cout<<sum<<endl;
    return 0;
}
